package StringHomeWork;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        String line="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random random=new Random();
        String code="";
        for (int i = 0; i < 4; i++) {
            int index= random.nextInt(line.length());
            char c=line.charAt(index);
            code+=c;
        }
        System.out.println("验证码"+code);
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入验证码");
        String input=scanner.nextLine();
        if (code.equalsIgnoreCase(input)){
            System.out.println("输入正确");
        }else {
            System.out.println("输入错误");
        }


    }
}
